package com.whj.servicepassengeruser.controller;

import com.whj.internalcommon.dto.ResponseResult;
import com.whj.internalcommon.request.VerificationCodeDTO;
import com.whj.servicepassengeruser.servie.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: wanghaijun
 * @Date: 2022/12/28 - 12 - 28 - 13:53 
 * @Description: com.whj.servicepassengeruser.controller
 */

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/user")
    public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO){
        System.out.println(verificationCodeDTO.getPassengerPhone());
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        return userService.loginOrRegister(passengerPhone);
    }

    @GetMapping("/user/{phone}")
    public ResponseResult getUserByPhone(@PathVariable("phone") String passengerPhone){
        return userService.getUserByPhone(passengerPhone);
    }
}
